﻿Public Class IcoNote

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        ColorDialog1.ShowDialog()
        RichTextBox1.SelectionColor = ColorDialog1.Color
    End Sub

    Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
        FontDialog1.Font = New Font("Arial", 11.0)
        FontDialog1.ShowDialog()
        RichTextBox1.SelectionFont = FontDialog1.Font
    End Sub

    Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
        ColorDialog2.ShowDialog()
        RichTextBox1.BackColor = ColorDialog2.Color
    End Sub

    Private Sub PictureBox4_Click(sender As Object, e As EventArgs) Handles PictureBox4.Click
        ContextMenuStrip1.Show()
    End Sub

    'This will makes IcoNote listen keyDown event when implemented in application
    Private Sub IcoNote_ParentChanged(sender As Object, e As EventArgs) Handles Me.ParentChanged
        DirectCast(Me.ParentForm, Form).KeyPreview = True
        AddHandler DirectCast(Me.ParentForm, Form).KeyDown, AddressOf IcoNote_KeyDown
    End Sub


    Private Sub IcoNote_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Space Then
            'general
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace(":)", "\u9786")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("<3", "\u9829")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*male", "\u9794")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*female", "\u9792")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("^tm", "\'99")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("(c)", "\'a9")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("(r)", "\'ae")

            'arrow
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("|^", "\u8593")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("->", "\u8594")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("|v", "\u8595")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("<-", "\u8592")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("^|v", "\u8597")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("<->", "\u8596")
            'mathematic
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("<=", "\u8804")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("=>", "\u8805")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("!=", "\u8800")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("+-", "\'b1")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*deg", "\'b0")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*sqrt", "\u8730")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*sigma", "\u8721")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*integral", "\u8747")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*infinity", "\u8734")
            'greek variables
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*alpha", "\'e1")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*beta", "β")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*gamma", "\u915")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*delta", "\u916")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*tetha", "\u920")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*lamda", "\u923")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*mu", "\u956")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*pi", "\u960")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*rho", "\u961")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("*omega", "\u937")
            'numbers
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("^2", "\'b2")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("^3", "\'b3")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("1/2", "\'bd")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("1/3", "\u8531")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("1/4", "\'bc")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("1/5", "\u8533")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("1/8", "\u8539")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("2/3", "\u8532")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("2/5", "\u8534")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("3/4", "\'be")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("3/5", "\u8535")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("3/8", "\u8540")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("4/5", "\u8536")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("5/8", "\u8541")
            RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("7/8", "\u8542")

            RichTextBox1.SelectionStart = RichTextBox1.TextLength
        End If
    End Sub

    'CONTEXT MENU
    'general context menu
    Private Sub ToolStripMenuItem2_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem2.Click
        RichTextBox1.AppendText("☺")
    End Sub
    Private Sub ToolStripMenuItem3_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem3.Click
        RichTextBox1.AppendText("♥")
    End Sub
    Private Sub MaleToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MaleToolStripMenuItem.Click
        RichTextBox1.AppendText("♂")
    End Sub
    Private Sub FemaleToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FemaleToolStripMenuItem.Click
        RichTextBox1.AppendText("♀")
    End Sub
    Private Sub TmToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles TmToolStripMenuItem1.Click
        RichTextBox1.AppendText("™")
    End Sub
    Private Sub CToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CToolStripMenuItem.Click
        RichTextBox1.AppendText("©")
    End Sub
    Private Sub RToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RToolStripMenuItem.Click
        RichTextBox1.AppendText("®")
    End Sub

    'arrow context menu
    Private Sub ToolStripMenuItem4_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem4.Click
        RichTextBox1.AppendText("↑")
    End Sub
    Private Sub ToolStripMenuItem5_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem5.Click
        RichTextBox1.AppendText("→")
    End Sub
    Private Sub VToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles VToolStripMenuItem.Click
        RichTextBox1.AppendText("↓")
    End Sub
    Private Sub ToolStripMenuItem6_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem6.Click
        RichTextBox1.AppendText("←")
    End Sub
    Private Sub VToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles VToolStripMenuItem1.Click
        RichTextBox1.AppendText("↕")
    End Sub
    Private Sub ToolStripMenuItem7_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem7.Click
        RichTextBox1.AppendText("↔")
    End Sub

    'mathematic context menu
    Private Sub ToolStripMenuItem8_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem8.Click
        RichTextBox1.AppendText("≤")
    End Sub
    Private Sub ToolStripMenuItem9_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem9.Click
        RichTextBox1.AppendText("≥")
    End Sub
    Private Sub ToolStripMenuItem10_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem10.Click
        RichTextBox1.AppendText("≠")
    End Sub
    Private Sub ToolStripMenuItem11_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem11.Click
        RichTextBox1.AppendText("±")
    End Sub
    Private Sub DegToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DegToolStripMenuItem.Click
        RichTextBox1.AppendText("°")
    End Sub
    Private Sub SqrtToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SqrtToolStripMenuItem.Click
        RichTextBox1.AppendText("√")
    End Sub
    Private Sub SigmaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SigmaToolStripMenuItem.Click
        RichTextBox1.AppendText("∑")
    End Sub
    Private Sub IntegralToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles IntegralToolStripMenuItem.Click
        RichTextBox1.AppendText("∫")
    End Sub
    Private Sub InfinityToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles InfinityToolStripMenuItem.Click
        RichTextBox1.AppendText("∞")
    End Sub

    'greek variables context menu
    Private Sub AlphaΑToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AlphaΑToolStripMenuItem.Click
        RichTextBox1.AppendText("α")
    End Sub
    Private Sub BetaΒToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BetaΒToolStripMenuItem.Click
        RichTextBox1.AppendText("β")
    End Sub
    Private Sub GammaΓToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles GammaΓToolStripMenuItem.Click
        RichTextBox1.AppendText("γ")
    End Sub
    Private Sub DeltaΔToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DeltaΔToolStripMenuItem.Click
        RichTextBox1.AppendText("δ")
    End Sub
    Private Sub TethaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TethaToolStripMenuItem.Click
        RichTextBox1.AppendText("θ")
    End Sub
    Private Sub LamdaΛToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LamdaΛToolStripMenuItem.Click
        RichTextBox1.AppendText("λ")
    End Sub
    Private Sub MuΜToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MuΜToolStripMenuItem.Click
        RichTextBox1.AppendText("μ")
    End Sub
    Private Sub PΠToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles PΠToolStripMenuItem.Click
        RichTextBox1.AppendText("π")
    End Sub
    Private Sub RhoΡToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RhoΡToolStripMenuItem.Click
        RichTextBox1.AppendText("ρ")
    End Sub
    Private Sub OmegaΩToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OmegaΩToolStripMenuItem.Click
        RichTextBox1.AppendText("Ω")
    End Sub

    'numbers context menu
    Private Sub ToolStripMenuItem13_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem13.Click
        RichTextBox1.AppendText("²")
    End Sub
    Private Sub ToolStripMenuItem14_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem14.Click
        RichTextBox1.AppendText("³")
    End Sub
    Private Sub ToolStripMenuItem15_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem15.Click
        RichTextBox1.AppendText("½")
    End Sub
    Private Sub ToolStripMenuItem16_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem16.Click
        RichTextBox1.AppendText("⅓")
    End Sub
    Private Sub ToolStripMenuItem17_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem17.Click
        RichTextBox1.AppendText("¼")
    End Sub
    Private Sub ToolStripMenuItem18_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem18.Click
        RichTextBox1.AppendText("⅛")
    End Sub
    Private Sub ToolStripMenuItem19_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem19.Click
        RichTextBox1.AppendText("⅔")
    End Sub
    Private Sub ToolStripMenuItem20_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem20.Click
        RichTextBox1.AppendText("¾")
    End Sub
    Private Sub ToolStripMenuItem21_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem21.Click
        RichTextBox1.AppendText("⅜")
    End Sub
    Private Sub ToolStripMenuItem22_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem22.Click
        RichTextBox1.AppendText("⅝")
    End Sub
    Private Sub ToolStripMenuItem23_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem23.Click
        RichTextBox1.AppendText("⅞")
    End Sub


    ' ADDITIONAL PROPERTY
    Public Property TextBoxValue() As String
        Get
            Return Me.RichTextBox1.Text
        End Get
        Set(ByVal Value As String)
            RichTextBox1.Text = Value
        End Set
    End Property

    Public Property PalleteSize() As Size
        Get
            Return Me.PictureBox1.Size
            Return Me.PictureBox2.Size
            Return Me.PictureBox3.Size
            Return Me.PictureBox4.Size
        End Get
        Set(ByVal palSize As Size)
            PictureBox1.Size = palSize
            PictureBox2.Size = palSize
            PictureBox3.Size = palSize
            PictureBox4.Size = palSize
        End Set
    End Property

    Public Property RTBSize() As Size
        Get
            Return Me.RichTextBox1.Size
        End Get
        Set(rSize As Size)
            RichTextBox1.Size = rSize
        End Set
    End Property

    Public Property BGColor() As Color
        Get
            Return Me.ColorDialog2.Color
        End Get
        Set(BGCvalue As Color)
            ColorDialog2.Color = BGCvalue
        End Set
    End Property

    Public Property FColor() As Color
        Get
            Return Me.ColorDialog1.Color
        End Get
        Set(FCvalue As Color)
            ColorDialog1.Color = FCvalue
        End Set
    End Property

    Public Property PalleteVisible() As Boolean
        Get
            Return Me.PictureBox1.Visible
            Return Me.PictureBox2.Visible
            Return Me.PictureBox3.Visible
            Return Me.PictureBox4.Visible
        End Get
        Set(pv As Boolean)
            PictureBox1.Visible = pv
            PictureBox2.Visible = pv
            PictureBox3.Visible = pv
            PictureBox4.Visible = pv
        End Set
    End Property

    Private Sub IcoNote_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
End Class
